home *** CD-ROM | disk | FTP | other *** search
/ Programming an RTS Game with Direct3D / Programming an RTS Game with Direct3D.iso / Examples / Chapter 4 / Example 4.3 / heightMap.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-06-29  |  970 b   |  48 lines

  1. #include <d3dx9.h>
  2. #include "intpoint.h"
  3.  
  4. #define LEFT 0
  5. #define RIGHT 1
  6. #define UP 2
  7. #define DOWN 3
  8.  
  9. struct PARTICLE{
  10.     D3DXVECTOR3 position;
  11.     D3DCOLOR color;
  12.     static const DWORD FVF;
  13. };
  14.  
  15. struct HEIGHTMAP
  16. {
  17.     //Functions
  18.     HEIGHTMAP(IDirect3DDevice9* Dev, INTPOINT _size);
  19.     ~HEIGHTMAP();
  20.     void Release();
  21.  
  22.     HRESULT LoadFromFile(char fileName[]);
  23.     HRESULT CreateRandomHeightMap(int seed, float noiseSize, float persistence, int octaves);
  24.  
  25.     HRESULT CreateParticles();
  26.     void Render();
  27.     D3DXVECTOR2 GetCentre(){return D3DXVECTOR2(m_size.x / 2.0f, m_size.y / 2.0f);}
  28.  
  29.     void MoveRect(int dir);
  30.     void RaiseTerrain(RECT r, float f);
  31.     void SmoothTerrain();
  32.  
  33.     //variables
  34.     INTPOINT m_size;
  35.     float m_maxHeight;
  36.     float *m_pHeightMap;
  37.     RECT m_selRect;
  38.  
  39.     //Vertex buffer for points
  40.     IDirect3DVertexBuffer9 *m_pVb;
  41.  
  42.     //Our device
  43.     IDirect3DDevice9* m_pDevice; 
  44.  
  45.     //Sprite
  46.     ID3DXSprite *m_pSprite;
  47.     IDirect3DTexture9 *m_pHeightMapTexture;
  48. };